//
//  CC_ImageViewAndTwoLabel_CollectionViewCell.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_ImageViewAndTwoLabel_CollectionViewCell.h"
#import "CCBaseMainTitleLabel.h"
#import "CCBaseSubHeadLabel.h"

#import "CC_Recommend_Model.h"

@interface CC_ImageViewAndTwoLabel_CollectionViewCell ()

@property(nonatomic, retain)UIImageView *imageView;
@property(nonatomic, retain) CCBaseMainTitleLabel *mainTitleLabel;
@property(nonatomic, retain) CCBaseSubHeadLabel *subHeadLabel;

@property(nonatomic, retain) UIImageView *littleCircle;

@end


@implementation CC_ImageViewAndTwoLabel_CollectionViewCell

- (void)dealloc
{
    
    [_recommendModel release];
    
    [_littleCircle release];
    [_imageView release];
    [_mainTitleLabel release];
    [_subHeadLabel release];
    [super dealloc];
}


-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.imageView = [[UIImageView alloc]init];
//        self.imageView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageView];
        [_imageView release];
        
        self.mainTitleLabel = [[CCBaseMainTitleLabel alloc]init];
//        self.mainTitleLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_mainTitleLabel];
        [_mainTitleLabel release];
        
        
        self.littleCircle = [[UIImageView alloc]init];
        self.littleCircle.image = [UIImage imageNamed:@"netsound_del@2x.png"];

        [self.contentView addSubview:_littleCircle];
        [_littleCircle release];
        
        
        
        self.subHeadLabel = [[CCBaseSubHeadLabel alloc]init];
//        self.subHeadLabel.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:_subHeadLabel];
        [_subHeadLabel release];
//        NSLog(@" ____________%.2f", frame.size.width);
//        NSLog(@"d个地方虎岛和夫会后悔init: %.2f", self.contentView.frame.size.width);
        
    }
    return self;
}

-(void)layoutSubviews{
    
    [super layoutSubviews];
    
//    NSLog(@"layout ::%.2f", self.contentView.frame.size.width);
    self.imageView.frame = CGRectMake(0, 0, (SCREENWIDTH - 6 * SPACED) / 3 , (SCREENWIDTH - 6 * SPACED) / 3 );
    
    [self.mainTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(_imageView.frame.size.width, _imageView.frame.size.height * 0.35));
        make.top.equalTo(self.imageView.mas_bottom).offset(SPACED);
        make.left.equalTo(self.contentView.mas_left).offset(0);
        
    }];
    
    [self.littleCircle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SPACED * 1.5, SPACED * 1.5));
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
        
    }];
    
//    self.littleCircle.image = [UIImage imageNamed:@"netsound_del@2x.png"];
    
    
    [self.subHeadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.mainTitleLabel.mas_bottom).offset(SPACED);
        make.left.equalTo(self.littleCircle.mas_right).offset(SPACED / 4);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        

    }];
    
    
}


-(void)setRecommendModel:(CC_Recommend_Model *)recommendModel{
    
    if (_recommendModel != recommendModel) {
        [_recommendModel release];
        _recommendModel = [recommendModel retain];
    }
    
    [self.imageView setImageWithURL:[NSURL URLWithString:recommendModel.coverMiddle]];
    self.mainTitleLabel.text = recommendModel.trackTitle;
    self.subHeadLabel.text = recommendModel.title;
    
}



@end
